package com.gt.quality.base;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author Administrator
 */

@AllArgsConstructor
@Getter
public enum UserSexEnum {

    Man(0, "男"),
    Woman(1, "女"),
    Default(2, "未知");

    private final Integer code;

    private final String desc;

    public static UserSexEnum buildSexInfo(Integer code) {
        UserSexEnum[] values = UserSexEnum.values();
        for (UserSexEnum value : values) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return Default;
    }

    public static UserSexEnum buildSexInfo(String desc) {
        UserSexEnum[] values = UserSexEnum.values();
        for (UserSexEnum value : values) {
            if (value.getDesc().equals(desc)) {
                return value;
            }
        }
        return Default;
    }
}
